﻿<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec"
	uri="http://www.springframework.org/security/tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<sec:authentication property="principal" var="currentPrincipal"
	scope="page" />

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<!DOCTYPE html>
<html lang="zh-CN">
<head>

<%@ include file="/WEB-INF/include/meta.jsp"%>
<%@ include file="/WEB-INF/include/css.jsp"%>

</head>

<body class="ms-theme-blue">

	<%@ include file="/WEB-INF/include/header.jsp"%>
	<%@ include file="/WEB-INF/include/submenu.jsp"%>

	<div class="container-fluid ms-container has-ms-sidemenu">

		<ol class="ms-breadcrumb breadcrumb">
			<li class="active">代理管理&nbsp;-&nbsp;代理员审核</li>
		</ol>

		<div class="ms-content-layout">
			<div class="x-operation-bar no-margin no-bottom-border clearfix">

				<ul class="nav nav-tabs ms-nav-tabs" role="tablist">
					<c:if test="${currentPrincipal.saleUser}">
					<li role="presentation" class="${status.created ? 'active' : ''}"><a href="${ctx.host}/agent-audits?status=CREATED">待分配</a></li>
					</c:if>
					<li role="presentation" class="${status.authing ? 'active' : ''}"><a href="${ctx.host}/agent-audits?status=AUTHING">待审核</a></li>
					<li role="presentation" class="${status.reject ? 'active' : ''}"><a href="${ctx.host}/agent-audits?status=REJECT">已驳回</a></li>
					<li role="presentation" class="${status.finished ? 'active' : ''}"><a href="${ctx.host}/agent-audits?status=FINISHED">合格</a></li>
				</ul>

				<div class="ms-operation-bar no-margin no-bottom-border clearfix">
					<div class="ms-operation-group">
						<div class="pull-right">
							<a href="${ctx.host}/agent-audits/search?status=${status}" data-target="#search"
								data-toggle="modal" class="btn ms-btn ms-btn-blue"> <i
								class="glyphicon glyphicon-search"></i>&nbsp;&nbsp;过滤查询
							</a>
						</div>
					</div>
				</div>

				<table class="table table-hover ms-table">
					<thead>
						<tr>
						<th>序号</th>
							<th>Email</th>						
							<th>姓名</th>
							<th>手机</th>
							<th>关联分区</th>
							<th>代理类型</th>
							<th>公司名称</th>
							<th>公司地址</th>
							<th>所属销售</th>
							<c:if test= "${status.finished}">
							<th>是否冻结</th>
							</c:if>
							<th>申请时间</th>
							<th class="text-center">操作</th>
						</tr>
					</thead>
					<tbody>
						<c:forEach items="${agentApplies}" var="agentApplies" varStatus="status">
							<tr>
							<td>${status.index+1}</td>		
								<td>${agentApplies.email}</td>							
								<td>${agentApplies.name}</td>
								<td>${agentApplies.mobile}</td>
								<td>${agentApplies.district.name}</td>
								<td>${agentApplies.type.description}</td>
								<td>${agentApplies.companyName}</td>
								<td>${agentApplies.companyAddress}</td>
								<td>${agentApplies.principal.name}</td>
								<c:if test="${agentApplies.status.finished}">
								<td>${agentApplies.disabled ? '是':'否'}</td>
								</c:if>
								<td><fmt:formatDate value="${agentApplies.createTime}" pattern="yyyy-MM-dd HH:MM:ss" /></td>
								<td class="text-center">
								<c:choose>
								 <c:when test="${agentApplies.status.created}">
								 	 <a href="${ctx.host}/agent-audits/${agentApplies.id}/edit" data-toggle="modal" data-target="#edit">编辑</a>&nbsp;&nbsp;
								   <a href="${ctx.host}/agent-audits/${agentApplies.id}/principal" data-toggle="modal" data-target="#principal">指定销售</a>&nbsp;&nbsp;
								  <c:if test = "${currentPrincipal.saleUser}">
								  	<a href="${ctx.host}/agent-audits/${agentApplies.id}/district" data-toggle="modal" data-target="#district">切换分区</a>
								  </c:if>
								</c:when>
								 <c:when test="${agentApplies.status.finished}">
								   <a href="${ctx.host}/agent-audits/${agentApplies.id}">详情</a>
								   <c:if test="${agentApplies.disabled == false}">
								   	 <a href="${ctx.host}/agent-audits/${agentApplies.id}/frost" data-toggle="modal" data-target="#frost">冻结</a>
								   </c:if>
								   <c:if test="${agentApplies.disabled == true}">
								   	 <a href="${ctx.host}/agent-audits/${agentApplies.id}/activation" data-toggle="modal" data-target="#activate">激活</a>
								   </c:if>
								   
								 </c:when>
								<c:when test="${agentApplies.status.authing}">
								    <a href="${ctx.host}/agent-audits/${agentApplies.id}/edit" data-toggle="modal" data-target="#edit">编辑</a>&nbsp;&nbsp;
								    <a href="${ctx.host}/agent-audits/${agentApplies.id}/verified" data-toggle="modal" data-target="#verified">审核通过</a>&nbsp;&nbsp;
								 	<a href="${ctx.host}/agent-audits/${agentApplies.id}/reject" data-toggle="modal" data-target="#reject">驳回</a>
								 	<c:if test="${agentApplies.type == 'COMPANY'}">
								 	<a href="${ctx.host}/agent-audits/${agentApplies.id}/assignCompany" data-toggle="modal" data-target="#assignCompany">分派公司</a>
								 	</c:if>
								 	<c:if test = "${currentPrincipal.saleUser}">
								  	<a href="${ctx.host}/agent-audits/${agentApplies.id}/district" data-toggle="modal" data-target="#district">切换分区</a>
								  	<a href="${ctx.host}/agent-audits/${agentApplies.id}/editPrincipal" data-toggle="modal" data-target="#editPrincipal">更换销售</a>
								    </c:if>
					            </c:when>
								 <c:when test="${agentApplies.status.reject}">
								 	 <a href="${ctx.host}/agent-audits/${agentApplies.id}/edit" data-toggle="modal" data-target="#edit">编辑</a>&nbsp;&nbsp;
								    <a href="${ctx.host}/agent-audits/${agentApplies.id}/activate" data-toggle="modal" data-target="#activate">激活</a>
								 </c:when>
								</c:choose>
								</td>
							</tr>
						</c:forEach>
					</tbody>
					<tfoot>
						<tr>
							<td colspan="12" class="no-vertical-padding">
								<div class="pull-left">
									<jsp:include page="/WEB-INF/include/page.jsp">
										<jsp:param name="url" value="${ctx.host}/agent-audits" />
										    <jsp:param name="queryString" value="${queryString}"/>
									</jsp:include>
								</div>
							</td>
						</tr>
					</tfoot>

				</table>

			</div>

		</div>

	</div>

	<%@ include file="/WEB-INF/include/footer.jsp"%>
	<%@ include file="/WEB-INF/include/script.jsp"%>
	<d:resource type="script" root="${ctx.resource}/build"
		src="js/page/agent/audit/agent-audit-list.js" />
	<script type="text/javascript">
		require([ 'page/agent/audit/agent-audit-list' ], function(page) {
			page.init()
		})
	</script>

</body>
</html>